home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / write_spr.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  79 lines

  1. ;$Id: write_spr.pro,v 1.7 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1994-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5. ;+
  6. ; NAME:
  7. ;       WRITE_SPR
  8. ;
  9. ; PURPOSE:
  10. ;       This procedure writes a row-indexed sparse matrix stucture to a 
  11. ;    specified file.  A  row-indexed sparse matrix is created by the
  12. ;    Numerical Recipes routine SPRSIN.
  13. ;
  14. ; CATEGORY:
  15. ;       Sparse Matrix File I/O 
  16. ;
  17. ; CALLING SEQUENCE:
  18. ;       WRITE_SPR, AS, 'Filename' 
  19. ;
  20. ; INPUTS:
  21. ;       AS:  row indexed sparse matrix created by SPRSIN
  22. ;    Filename:  Name of file to contain AS.
  23. ;
  24. ; KEYWORDS:
  25. ;    NONE
  26. ;
  27. ; OUTPUTS:
  28. ;    NONE
  29. ;
  30. ; EXAMPLE:
  31. ;    a = [[3.,0., 1., 0., 0.],$
  32. ;         [0.,4., 0., 0., 0.],$
  33. ;              [0.,7., 5., 9., 0.],$
  34. ;              [0.,0., 0., 0., 2.],$
  35. ;              [0.,0., 0., 6., 5.]]
  36. ;
  37. ;    as = SPRSIN(a)
  38. ;
  39. ;    WRITE_SPR, as, 'sprs.as'
  40. ;
  41. ; MODIFICATION HISTORY:
  42. ;       Written by:     BMH, 1/94.
  43. ;       Modified:       GGS, RSI, July 1996
  44. ;                       Changed NR_SPRSIN to SPRSIN.
  45. ;-
  46.  
  47. PRO WRITE_SPR, as, filename
  48.  
  49. ; as structure format = {sa:FLTARR(nmax) or sa:DBLARR(nmax),  - value array
  50. ;             ija:LONARR(nmax)}                    - index array
  51. ;
  52.  
  53. ON_IOERROR, BADFILE
  54. info = SIZE(as.(0))   ;Access type and size information for the sa array 
  55.  
  56. nmax = info[1] ;sa and ija vectors are of equal length. 
  57. type = info[2] ;Type of matrix value vector (sa)
  58.  
  59. OPENW, fileLUN, filename, /GET_LUN
  60.  
  61. ;Store type and size info for file read 
  62. WRITEU, fileLUN, nmax, type, as  
  63.  
  64. FREE_LUN, fileLUN
  65.  
  66.  
  67. RETURN
  68.  
  69. BADFILE:
  70. IF (N_Elements(fileLUN) GT 0L) THEN $
  71.    FREE_LUN, fileLUN
  72. MESSAGE, 'Error writing to sparse matrix file: ' + filename
  73.  
  74.  
  75. END
  76.  
  77.  
  78.  
  79.